<%@page import="org.apache.commons.lang.StringUtils"%>
<%@page import="org.apache.commons.lang.time.DateFormatUtils"%>
<%@page import="org.springframework.util.CollectionUtils"%>
<%@page import="cn.com.xf.common.Constants"%>
<%@page import="java.util.Collection"%>
<%@ include file="../common/common_include.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	List<TblRegVisitor> list = (List<TblRegVisitor>)request.getAttribute("list");
	Map<String,Object> intraday = (Map<String,Object>)request.getAttribute("intraday");
	VisitorForm form = (VisitorForm)request.getAttribute("command");
	String visittimeStart = StringUtils.isNotBlank(form.getVisittimeStart())?form.getVisittimeStart():"";
	String visittimeEnd = StringUtils.isNotBlank(form.getVisittimeEnd())?form.getVisittimeEnd():"";
    String username = StringUtils.isNotBlank(form.getUsername())?form.getUsername():"";
    String vname = StringUtils.isNotBlank(form.getVname())?form.getVname():"";
    String vid = (null!=form.getVid())?form.getVid()+"":"";
	UserInfo user = (UserInfo)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
%>

<div class="userListWrap">
    <form id="userListForm">    
    <div class="box">
        <div class="form-item" >
    		<label for="username">值班保安:</label>
    		<input class="easyui-validatebox" type="text" style="width:100px" name="username" data-options="" value="<%= username%>"/>
        </div>
        <div class="form-item">
    		<label for="vname">访客:</label>
    		<input class="easyui-validatebox" type="text" style="width:100px" name="vname" data-options="" value="<%= vname%>" />
        </div>
        <div class="form-item">
    		<label for="vname">条形码:</label>
    		<input class="easyui-validatebox" type="text" style="width:100px" name="vid" data-options="" value="<%= vid%>"/>
        </div>
     </div>
     <div class="box">
       	<div class="form-item form-item-two">
    		<label  for="visittime">访问时间:</label>
    		<input class="easyui-validatebox" style="width:100px" id="visittimeStart" name="visittimeStart" type="text" 	onClick="WdatePicker({errDealMode:1,dateFmt:'yyyy-M-d',minDate:'2017-1-1',maxDate:'%y-%M-%d'})" value="<%= visittimeStart%>">--
    		<input class="easyui-validatebox" style="width:100px" id="visittimeEnd" name="visittimeEnd" type="text"  onClick="WdatePicker({errDealMode:1,dateFmt:'yyyy-M-d',minDate:'2017-1-1',maxDate:'%y-%M-%d'})" value="<%= visittimeEnd%>">
        </div>
        <div class="form-item" style="width:80px">
    		<a href="javascript:XF.Visitor.listVisitorSearch()" class="input-btn-microsoft input-btn-microsoft-24">搜索</a>
        </div>
     </div>       
    </form>
    <table id="visitorListTable" class="easyui-datagrid"  >
        <thead>
    		<tr>
				<th data-options="field:'vname',width:60">访客姓名</th>				
				<th data-options="field:'certtype',width:60">证件类型</th>				
				<th data-options="field:'cert',width:100">证件号码</th>
    			<th data-options="field:'units',width:90">访客单位</th>
    			<th data-options="field:'phone',width:95">联系电话</th>
    			<th data-options="field:'peoplenum',width:40">人数</th>					
				<th data-options="field:'byvisitor',width:60">被访人</th>
				<th data-options="field:'depa',width:100" >被访部门</th>
				<th data-options="field:'aim',width:75" >事由</th>
				<th data-options="field:'visittime',width:130" >访问时间</th>
				<th data-options="field:'qrcode',width:75" >打印信息</th>
				<th data-options="field:'photo',width:50" >相片</th>
				<th data-options="field:'pro',width:80">操作</th>
				<th data-options="field:'outtime',width:130" >离开时间</th>
				<th data-options="field:'username',width:60" >值班保安</th>					
				<th data-options="field:'remark',width:140">备注</th>
				
      		</tr>
        </thead>
        <tbody>
        	<%
        		if(list!=null && list.size() > 0){
        			for(TblRegVisitor visitor:list){
        				%>
       					 <tr s="<%=visitor.getVid() %>"> 					 	      					 	
       					 	<td><i s="<%=visitor.getVid() %>"></i><%=(null!=visitor.getVname())?visitor.getVname()+"":"" %></td>       					 	
       					 	<td><% String certtype = "身份证";
       					 		if(visitor.getCerttype().equals("0")){
       					 			certtype = "身份证";%>
       					 			<%=certtype %>
       					 		<%}else if(visitor.getCerttype().equals("1")){
       					 			certtype = "其它";%>
       					 			<%=certtype %>
       					 		<%}else{
       					 			String type = "";%>
       					 			<%=type %>
       					 		<%}%></td>
       					 	<td><%=(null!=visitor.getCert())?visitor.getCert()+"":"" %></td>
       					 	<td><%=(null!=visitor.getUnits())?visitor.getUnits()+"":"" %></td>
       					 	<td><%=(null!=visitor.getPhone())?visitor.getPhone()+"":"" %></td>
       					 	<td><%=(null!=visitor.getPeoplenum())?visitor.getPeoplenum()+"":"" %></td>
       					 	<td><%=(null!=visitor.getByvisitor())?visitor.getByvisitor()+"":"" %></td>
       					 	<td><%=(null!=visitor.getDepa())?visitor.getDepa()+"":"" %></td>
       					 	<td><%=(null!=visitor.getAim())?visitor.getAim()+"":"" %></td>
       					 	<td><%=null!=visitor.getVisittime()?DateFormatUtils.format(visitor.getVisittime().getTime(), "yyyy-MM-dd HH:mm:ss"):"" %></td>
       					 	<td><a id="printInfo" class="a-btn-microsoft" href="javascript:XF.Visitor.printInfo('<%=visitor.getVid()+"" %>','<%=visitor.getVname()+"" %>','<%=certtype %>','<%=(null!=visitor.getCert())?visitor.getCert()+"":"" %>','<%=(null!=visitor.getUnits())?visitor.getUnits()+"":"" %>','<%=(null!=visitor.getPhone())?visitor.getPhone()+"":"" %>','<%=visitor.getPeoplenum()+"" %>','<%=(null!=visitor.getByvisitor())?visitor.getByvisitor()+"":"" %>','<%=(null!=visitor.getDepa())?visitor.getDepa()+"":"" %>','<%=visitor.getAim()+"" %>','<%=null!=visitor.getVisittime()?DateFormatUtils.format(visitor.getVisittime().getTime(), "yyyy-MM-dd HH:mm"):"" %>','<%=(null!=visitor.getRemark())?visitor.getRemark()+"":"" %>')" >打印信息</a></td>
       					 	<td>	
       					 		<%if(visitor.getPhotoname() == null || visitor.getPhotoname().equals("") ){%>       					 			
       					 			<%="" %>
       					 		<%}else{
       								String photoname =visitor.getPhotoname(); 	%>
       					 			<a id="openImg" class="a-btn-microsoft" href="javascript:XF.Visitor.openImg('<%=photoname %>')">相片</a>
       					 		<%}%>
       					 	</td>
       					 	<td>
									<a class="inLink" href="javascript:XF.Visitor.editVisitor('<%=visitor.getVid()+"" %>')"><span>编辑</span></a>									
									<a class="inLink"  href="javascript:XF.Visitor.doOut('<%=visitor.getVid()+"" %>')" >离开</a>
							</td>
							<td><%=null!=visitor.getOuttime()?DateFormatUtils.format(visitor.getOuttime().getTime(), "yyyy-MM-dd HH:mm:ss"):"" %></td>
       					 	<td><%=(null!=visitor.getUsername())?visitor.getUsername()+"":"" %></td>
       					 	<td><%=(null!=visitor.getRemark())?visitor.getRemark()+"":"" %></td>				    		
			    		</tr>
        				<%
        			}
        		}
        	%>
    	</tbody>
    </table>
    <div class="pagination paginationFixWidth">
		<monggoTag:pagination 
		href="visitor_search"
		pageSize="<%=form.getPageSize()%>" 
		totalRecord="<%=form.getTotalRecord() %>" 
		currentPage="<%=form.getPageNum() %>">
		</monggoTag:pagination> 
	</div>
	<div>
		<p>今日登记人数：<font color="blue"><%=intraday.get("intradayCount") %></font>，未离开人数：<font color="red"><%=intraday.get("notOutCount") %></font></p>
	</div>
</div>
	<div id="userdetail_popwin" closed="true" class="easyui-window" title="打印条形码" style="width:185px;height:400px;">
	</div>
<script>
	$("#userdetail_popwin").window();
	$('#visitorListTable').datagrid();
	<%-- $("#visittimeStart").datebox({
		formatter:XF.dateFormatter,
		parser:XF.dateParse
	});
	
	<%
	if(StringUtils.isNotBlank(visittimeStart)){
		%>
			$("#visittimeStart").datebox("setValue","<%=visittimeStart%>");
		<%
	}
	%> 

	$("#visittimeEnd").datebox({
		formatter:XF.dateFormatter,
		parser:XF.dateParse
	});
	
	<%
	if(StringUtils.isNotBlank(visittimeEnd)){
		%>
			$("#visittimeEnd").datebox("setValue","<%=visittimeEnd%>");
		<%
	}
	%>  --%>
	
</script>
<style type="text/css">
		#openImg{margin-left: 3px;padding-left: 4px;padding-right: 4px;}
		#printInfo{margin-left: 3px;padding-left: 4px;padding-right: 4px;}		
	</style>


